package com.it.sun.esaychat.chat.controller;

import com.alibaba.fastjson.JSON;
import com.it.sun.easychat.model.util.ResultHelper;
import com.it.sun.easychat.model.vo.ResultVO;
import com.it.sun.esaychat.chat.entity.MessageEntity;
import com.it.sun.esaychat.chat.service.IMessageSendServices;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.handler.annotation.MessageMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author sunmannian
 * @ClassName com.it.sun.esaychat.chat.controller.MessageSendController
 * @Date 2020/5/28 13:34
 * @Version V1.0
 * Description  <请输入一句话描述该类功能>
 * Copyright (C) 北京中电兴发科技有限公司  since 2020/5/28
 */
@RestController
@RequestMapping("/message/send")
@Api(tags = "消息发送服务")
@Slf4j
public class MessageSendController {

    @Autowired
    private IMessageSendServices messageSendServices;

    @PostMapping("/single")
    @ApiOperation("私聊消息,可使用http")
    public ResultVO<Void> single(@RequestBody MessageEntity messageEntity) {

        return ResultHelper.success();
    }

    @PostMapping("/room")
    @ApiOperation("群聊消息，可使用http")
    public ResultVO<Void> room(@RequestBody MessageEntity messageEntity) {
        return ResultHelper.success();
    }


    @MessageMapping("/single")
    @ApiOperation("私聊消息，只能使用websocket发送")
    public ResultVO<Void> singleWithSockJs(@RequestBody MessageEntity messageEntity) {
        log.info("single message is ==>{}", JSON.toJSONString(messageEntity));
        return ResultHelper.success();
    }

    @MessageMapping("/room")
    @ApiOperation("私聊消息，只能使用websocket发送")
    public ResultVO<Void> roomWithSockJs(@RequestBody MessageEntity messageEntity) {
        return ResultHelper.success();
    }
}
